from django.conf.urls import url, include
from web.views import account, project, manage, wiki, file, setting, issues, dashboard, statistics, price

urlpatterns = [
    url(r'^register/$', account.register, name='register'),
    url(r'^login/sms/$', account.login_sms, name='login_sms'),
    url(r'^login/$', account.login, name='login'),
    url(r'^image/code/$', account.get_image_code, name='image_code'),
    url(r'^send/sms/$', account.send_sms, name='send_sms'),
    url(r'^logout/$', account.logout, name='logout'),
    url(r'^index/$', account.index, name='index'),
    url(r'^$', account.index, name='index'),

    # 价格套餐
    url(r'^price/$', price.price, name='price'),
    # 支付列表
    url(r'^price/payment/(?P<policy_id>\d+)/$', price.price_payment, name='price_payment'),
    # 创建支付订单
    url(r'^price/pay/$', price.pay, name='pay'),
    # 支付完成回调界面
    url(r'^pay/notify/$', price.pay_notify, name='pay_notify'),
    # 订单列表
    url(r'^order/list/$', price.order_list, name='order_list'),
    # 订单列表 立即支付
    url(r'^pay/now/(?P<transaction_id>\d+)/$', price.pay_now, name='pay_now'),
    # 取消订单
    url(r'^cancel/order/$', price.cancel_order, name='cancel_order'),

    # 项目列表
    url(r'^project/list/$', project.project_list, name='project_list'),
    url(r'^project/star/(?P<project_type>\w+)/(?P<project_id>\d+)/$', project.project_star, name='project_star'),
    url(r'^project/unstar/(?P<project_type>\w+)/(?P<project_id>\d+)/$', project.project_unstar, name='project_unstar'),

    # 进入单个项目管理
    url(r'^manage/(?P<project_id>\d+)/', include(
        [

            # wiki 文档库
            url(r'^wiki/$', wiki.wiki, name='wiki'),
            url(r'^wiki/add/$', wiki.wiki_add, name='wiki_add'),
            url(r'^wiki/catalog/$', wiki.wiki_catalog, name='wiki_catalog'),  # 显示多级目录
            url(r'^wiki/delete/(?P<wiki_id>\d+)/$', wiki.wiki_delete, name='wiki_delete'),
            url(r'^wiki/edit/(?P<wiki_id>\d+)/$', wiki.wiki_edit, name='wiki_edit'),
            url(r'^wiki/upload/$', wiki.wiki_upload, name='wiki_upload'),

            # 文件管理
            url(r'^file/$', file.file, name='file'),
            url(r'^file/delete/$', file.file_delete, name='file_delete'),
            url(r'^cos/credential/$', file.cos_credential, name='cos_credential'),  # 上传文件获取临时凭证
            url(r'^file/post/$', file.file_post, name='file_post'),  # 上传文件成功后，发送给后台文件相关数据
            url(r'^file/download/(?P<file_id>\d+)/$', file.download, name='download'),  # 下载上传后的文件到本地

            # 设置选项
            url(r'^setting/$', setting.setting, name='setting'),
            url(r'^setting/delete/$', setting.setting_delete, name='setting_delete'),
            url(r'^setting/set/password/$', setting.set_password, name='set_password'),

            # 问题管理
            url(r'^issues/$', issues.issues, name='issues'),
            url(r'^issues/detail/(?P<issues_id>\d+)/$', issues.issues_detail, name='issues_detail'),
            url(r'^issues/record/(?P<issues_id>\d+)/$', issues.issues_record, name='issues_record'),
            url(r'^issues/change/(?P<issues_id>\d+)/$', issues.issues_change, name='issues_change'),
            url(r'^issues/invite/url/$', issues.invite_url, name='invite_url'),

            # 概览部分
            url(r'^dashboard/$', dashboard.dashboard, name='dashboard'),
            url(r'^dashboard/issuesChart$', dashboard.issues_chart, name='issues_chart'),  # 问题图表显示
            url(r'^statistics/$', statistics.statistics, name='statistics'),
            url(r'^statistics/priority/$', statistics.statistics_priority, name='statistics_priority'),
            url(r'^statistics/project/user/$', statistics.statistics_project_user, name='statistics_project_user'),
        ]
        , None, None)),
    url(r'^invite/join/(?P<code>\w+)/$', issues.invite_join, name='invite_join'),
]
